package com.bw.mvvm_common.network;

import com.bw.mvvm_common.network.inteceptor.ErroInterceptor;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;

/**
 * @author KK
 * @description:
 * @date :2021/10/13 15:34
 */
public abstract class BaseImpl implements HttpInterface {

    protected OkHttpClient.Builder createOkHttpBuilder(){
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        builder.addInterceptor(interceptor);
        builder.addInterceptor(new ErroInterceptor());
        builder.callTimeout(30, TimeUnit.SECONDS);
        builder.writeTimeout(30, TimeUnit.SECONDS);
        builder.readTimeout(30, TimeUnit.SECONDS);
        return builder;
    }
}
